package com.kingyea.mobilepolice.userrole.service.impl;

import com.kingyea.mobilepolice.userrole.bean.UserRole;
import com.kingyea.mobilepolice.userrole.bean.UserRoleCondition;
import com.kingyea.mobilepolice.userrole.dao.UserRoleMapper;
import com.kingyea.mobilepolice.userrole.service.UserRoleService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Mr.Lin
 * @version v1.0.0
 * @description UserRole 实现类
 * @date Created in 2018-03-30 15:30:02
 */
@Service
@Transactional
public class UserRoleServiceImpl implements UserRoleService {

    private static final Logger LOGGER = LoggerFactory.getLogger(UserRoleServiceImpl.class);

    @Resource
    private UserRoleMapper userRoleMapper;

    /**
     * 通过ID查找对象
     *
     * @param id
     * @return
     */
    @Override
    public UserRole getById(Integer id) throws Exception {
        return this.userRoleMapper.getById(id);
    }

    /**
     * 列表
     *
     * @param
     * @return
     */
    @Override
    public List<UserRole> search(UserRoleCondition condition) throws Exception {
        List<UserRole> list = userRoleMapper.search(condition);
        return list;
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @Override
    public int deleteById(Integer id) throws Exception {
        userRoleMapper.deleteById(id);
        return 1;
    }

    /**
     * 保存
     *
     * @param userRole
     * @return
     */
    @Override
    public UserRole save(UserRole userRole) throws Exception {
        try {
            userRoleMapper.save(userRole);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return userRole;
    }

    /**
     * 更新
     *
     * @param userRole
     * @return
     */
    @Override
    public UserRole update(UserRole userRole) throws Exception {
        try {
            userRoleMapper.update(userRole);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return userRole;
    }


}
